<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>驴妈妈流立方</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${request.contextPath}/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/assets/font-awesome/4.7.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${request.contextPath}/assets/css/daterangepicker.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${request.contextPath}/assets/css/fonts.googleapis.com.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${request.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<link rel="stylesheet" href="${request.contextPath}/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/assets/css/ace-rtl.min.css" />
		<link rel="stylesheet" href="${request.contextPath}/assets/css/bootstrap-datetimepicker.min.css" />
		
		<link rel="stylesheet" href="${request.contextPath}/assets/css/jquery.gritter.min.css" />
		<!-- ace settings handler -->
		<script src="${request.contextPath}/assets/js/ace-extra.min.js"></script>
		<link rel="stylesheet" href="${request.contextPath}/assets/css/bsie-paginator.css" />
		<script src="${request.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript">
            $(function () {
                MergeCell('dynamic-table', 1, 0, 0);
            })

            function MergeCell(tableId, startRow, endRow, col) {
                var tb = document.getElementById(tableId);
                if (col >= tb.rows[0].cells.length) {
                    return;
                }
                //当检查第0列时检查所有行
                if (col == 0 || endRow == 0) {
                    endRow = tb.rows.length - 1;
                }

                for (var i = startRow; i < endRow; i++) {
                    //程序是自左向右合并
                    if (tb.rows[startRow].cells[col].innerHTML == tb.rows[i + 1].cells[col].innerHTML) {
                        //如果相同则删除下一行的第0列单元格
                        tb.rows[i + 1].cells[col].style.display = 'none';
                        //更新rowSpan属性
                        tb.rows[startRow].cells[col].rowSpan = (tb.rows[startRow].cells[col].rowSpan | 0) + 1;
                        //当循环到终止行前一行并且起始行和终止行不相同时递归(因为上面的代码已经检查了i+1行，所以此处只到endRow-1)
                        if (i == endRow - 1 && startRow != endRow) {
                            MergeCell(tableId, startRow, endRow, col + 1);
                        }
                    } else {
                        //起始行，终止行不变，检查下一列
                        MergeCell(tableId, startRow, i, col + 1);
                        //增加起始行
                        startRow = i + 1;
                    }
                }
            }
            /**
             * 翻页到指定页数
             */
            var showPage = function(page,obj) {
                var objId = $(obj).attr("id");//当前按钮的id
                var pages = $("#sp_1_grid-pager").html();//总页数
                var pageNum = $(".ui-pg-input").val();//当前页
                $("#page").val(page);
                if(pageNum == pages){
                    if(objId == "next_grid-pager" || objId == "last_grid-pager"){
                        return;
                    }
                }
                if(pageNum == 1){
                    if(objId == "prev_grid-pager" || objId == "first_grid-pager"){
                        return;
                    }
                }
                $("td").attr("onclick","");
                var action = $("#searchForm").attr("action");
                action = action + "?page=" + page;
                $("#searchForm").attr("action", action);
                $("#searchForm").submit();
            }

            $(".ui-pg-input").blur(function(){
                var objValue = $(".ui-pg-input").val();//文本框输入页数
                var pages = $("#sp_1_grid-pager").html();//总页数
                if(Number(objValue) > pages || Number(objValue) < 1){
                    return;
                }
                $("td").attr("onclick","");
                var action = $("#searchForm").attr("action");
                action = action + "?page=" + objValue;
                $("#searchForm").attr("action", action);
                $("#searchForm").submit();
            });
		</script>
	</head>

	<body class="skin-2" style="background-color: #FFF;">
		<div class="page-content">
			<div class="row">
				<div class="col-xs-12">
					<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
						<div class="row">
							<form class="form-inline" id="searchForm" method="post" action="${request.contextPath}/log/list">
								<input type="hidden" name="page" value=1 id=""/>
								<input type="hidden" name="pageSize" value=10 id="pageSize" />
								<input type="hidden" name="totalPages" value=${page.pages!} id="totalPages" />
								<div class="col-xs-2">
									<div class="dataTables_length">
										<label>用户名
											<input type="text" class="form-control" name="operator" value="${condition.operator!}" placeholder="查询用户名">
										</label>
									</div>
								</div>
								<div class="col-xs-2">
									<div class="dataTables_length">
										<label>请求地址
											<input type="text" class="form-control" name="requestUri" value="${condition.requestUri!}" placeholder="请求地址">
										</label>
									</div>
								</div>
								<div class="col-xs-2">
									<div class="dataTables_length">
										<label>开始时间
											<input type="text" class="form-control datetimepicker" name="beginDate" value="${condition.beginDate!}" placeholder="查询开始时间">
										</label>
									</div>
								</div>
								<div class="col-xs-2">
									<div class="dataTables_length">
										<label>结束时间
											<input type="text" class="form-control datetimepicker" name="endDate" value="${condition.endDate!}" placeholder="查询结束时间">
										</label>
									</div>
								</div>
								<div class="col-xs-2">
									<div class="dataTables_length">
										<button id="search" type="button" class="btn btn-pink btn-sm">
											<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
											查询
										</button>
									</div>
								</div>
							</form>
						</div>
						<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
							<thead>
								<tr>
									<th>No.</th>
									<th>用户名</th>
									<th>IP地址</th>
									<th>请求地址</th>
									<th>请求参数</th>
									<th>创建时间</th>
								</tr>
							</thead>
							<tbody>
								<#if logs?? && logs?size&gt;0>
									<#list logs as log>
											<td>${log_index + 1}</td>
											<td>${log.operator!}</td>
											<td>${log.remoteAddr!}</td>
											<td>${log.requestUri!}</td>
											<#if log.params?? && log.params?length&gt;50>
											<td title="${log.params!}">${log.params[0..50]!}...</td>
											<#else>
											<td>${log.params!}</td>
											</#if>
										<td><#if log.createDate ??>${log.createDate?string('yyyy-MM-dd HH:mm:ss')!}</#if></td>
										</tr>
									</#list>
								<#else>
									<tr>
										<td colspan="12">
											<div class="alert alert-danger" style="margin-bottom: 0px;" role="alert">没有记录!</div>
										</td>
									</tr>
								</#if>
							</tbody>
						</table>
						<div class="ui-jqgrid">
							<div id="grid-pager"
								 class="ui-state-default ui-jqgrid-pager ui-corner-bottom" dir="ltr">
								<div id="pg_grid-pager" class="ui-pager-control" role="group">
									<table cellspacing="0" cellpadding="0" border="0" class="ui-pg-table"
										   style="width: 100%; table-layout: fixed; height: 100%;" role="row">
										<tbody>
										<tr>
											<td id="grid-pager_left" align="left"></td>
											<td id="grid-pager_center" align="center"
												style="white-space: pre; width: 343px;"><table
													cellspacing="0" cellpadding="0" border="0"
													style="table-layout: auto;" class="ui-pg-table">
												<tbody>
												<tr>
													<td id="first_grid-pager" onclick="showPage(1,this)"
														class="ui-pg-button ui-corner-all <#if page.isFirstPage>ui-state-disabled</#if>"
														style="cursor: pointer;"><span
															class="ui-icon ace-icon fa fa-angle-double-left bigger-140"></span></td>
													<td id="prev_grid-pager" onclick="showPage(${page.prePage?c!},this)"
														class="ui-pg-button ui-corner-all <#if page.isFirstPage>ui-state-disabled</#if>"
														style="cursor: pointer;"><span
															class="ui-icon ace-icon fa fa-angle-left bigger-140"></span></td>
													<td dir="ltr">Page <input class="ui-pg-input" type="text"
																			  size="2" maxlength="7" value="${page.pageNum!}" role="textbox"> of <span
															id="sp_1_grid-pager">${page.pages!}</span></td>
													<td id="next_grid-pager" onclick="showPage(${page.nextPage?c!},this)" class="ui-pg-button ui-corner-all <#if page.isLastPage>ui-state-disabled</#if>"
														style="cursor: pointer;"><span
															class="ui-icon ace-icon fa fa-angle-right bigger-140"></span></td>
													<td id="last_grid-pager" onclick="showPage(${page.pages?c},this)" class="ui-pg-button ui-corner-all <#if page.isLastPage>ui-state-disabled</#if>"
														style="cursor: pointer;"><span
															class="ui-icon ace-icon fa fa-angle-double-right bigger-140"></span></td>
												</tr>
												</tbody>
											</table></td>
											<td id="grid-pager_right" align="right"><div dir="ltr"
																						 style="text-align: right" class="ui-paging-info">View ${page.startRow!} -
												${page.endRow!} of ${page.total!}</div></td>
										</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>		
		</div>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='${request.contextPath}/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="${request.contextPath}/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->
		<script src="${request.contextPath}/assets/js/jquery-ui.min.js"></script>
		<script src="${request.contextPath}/assets/js/jquery.ui.touch-punch.min.js"></script>

		<!-- ace scripts -->
		<script src="${request.contextPath}/assets/js/ace-elements.min.js"></script>
		<script src="${request.contextPath}/assets/js/ace.min.js"></script>
		<!-- user scripts -->
		<script src="${request.contextPath}/assets/js/user/base.js"></script>
		<script src="${request.contextPath}/assets/js/moment.min.js"></script>
		<script src="${request.contextPath}/assets/js/bootstrap-datetimepicker.min.js"></script>
		
		<script type="text/javascript">
			jQuery(function($) {
				var message = "";
				if(!isEmpty(message)) {
					showMsg(message);
				}
				
				var options = {
						format:'YYYY-MM-DD HH:mm:ss'
				}
				$('.datetimepicker').datetimepicker(options).next().on(ace.click_event, function(){
					$(this).prev().focus();
				});
				
				$("#search").on("click",function(){
					$(this).attr("disabled","true");
					$(this).attr("readOnly","true");
					$("#searchForm").submit();
				});
			})
		</script>
	</body>
</html>